import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '方案编码',
    align: 'center',
    dataIndex: 'caseCode',
    fixed: 'left',
    ifShow: false,
  },
  {
    title: '模块名称',
    align: 'center',
    dataIndex: 'caseName',
    fixed: 'left',
  },
  {
    title: '班组编码',
    align: 'center',
    dataIndex: 'orgCode',
    ifShow: false,
  },
  {
    title: '班组名称',
    align: 'center',
    dataIndex: 'orgName',
  },
  {
    title: '方案别称',
    align: 'center',
    dataIndex: 'nickName',
    editRow: true,
    editComponent: 'Input',
  },
  {
    title: '方案是否启用',
    align: 'center',
    dataIndex: 'caseStatus',
    editRow: true,
    editComponent: 'Switch',
  },
  // {
  //   title: '方案模块是否参与计算',
  //   align: 'center',
  //   dataIndex: 'caseCount',
  //   editRow: true,
  //   editComponent: 'Switch',
  // },
  {
    title: '折算方式',
    align: 'center',
    dataIndex: 'modeName',
    ifShow: false,
  },
  {
    title: '折算方式',
    align: 'center',
    editRow: true,
    dataIndex: 'modeCode',
  },
  {
    title: '权重%',
    align: 'center',
    dataIndex: 'weight',
    editRow: true,
    editComponent: 'InputNumber',
  },
  {
    title: '小数点位数',
    align: 'center',
    dataIndex: 'decimalPlaces',
    editRow: true,
    editComponent: 'InputNumber',
  },
  {
    title: '满分/分值上限',
    align: 'center',
    dataIndex: 'fullScore',
    editRow: true,
    editComponent: 'InputNumber',
  },
  {
    title: '排序',
    align: 'center',
    dataIndex: 'displayOrder',
    editRow: true,
    editComponent: 'Input',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'orgCode',
    component: 'Select',
    label: '班组1',
    componentProps: {
      options: userStore.getTeamList,
    },
    defaultValue: userStore.getOrgCode,
    colProps: { span: 8 },
  },
  {
    field: 'caseName',
    label: '模块名称',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '方案编码',
    field: 'caseCode',
    component: 'Input',
  },
  {
    label: '方案名称',
    field: 'caseName',
    component: 'Input',
  },
  {
    label: '班组编码',
    field: 'orgCode',
    component: 'Input',
  },
  {
    label: '班组名称',
    field: 'orgName',
    component: 'Input',
  },
  {
    label: '方案别称',
    field: 'nickName',
    component: 'Input',
  },
  {
    label: '方案是否启用',
    field: 'caseStatus',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入方案是否启用!' },
      ];
    },
  },
  {
    label: '方案模块是否参与计算',
    field: 'caseCount',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入方案模块是否参与计算!' },
      ];
    },
  },
  {
    label: '折算方式',
    field: 'modeCode',
    component: 'Input',
  },
  {
    label: '权重',
    field: 'weight',
    component: 'Input',
  },
  {
    label: '小数点位',
    field: 'decimalPlaces',
    component: 'InputNumber',
  },
  {
    label: '满分',
    field: 'fullScore',
    component: 'Input',
  },
  {
    label: '显示排序',
    field: 'displayOrder',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入显示排序!' },
      ];
    },
  },
  {
    label: '折算方式名称',
    field: 'modeName',
    component: 'Input',
  },
  {
    label: '储存字段',
    field: 'saveCode',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  caseCode: { title: '方案编码', order: 0, view: 'text', type: 'string', },
  caseName: { title: '方案名称', order: 1, view: 'text', type: 'string', },
  orgCode: { title: '班组编码', order: 2, view: 'text', type: 'string', },
  orgName: { title: '班组名称', order: 3, view: 'text', type: 'string', },
  nickName: { title: '方案别称', order: 4, view: 'text', type: 'string', },
  caseStatus: { title: '方案是否启用', order: 5, view: 'text', type: 'string', },
  caseCount: { title: '方案模块是否参与计算', order: 6, view: 'text', type: 'string', },
  modeCode: { title: '折算方式', order: 7, view: 'text', type: 'string', },
  weight: { title: '权重', order: 8, view: 'text', type: 'string', },
  decimalPlaces: { title: '小数点位', order: 9, view: 'number', type: 'number', },
  fullScore: { title: '满分', order: 10, view: 'text', type: 'string', },
  displayOrder: { title: '显示排序', order: 11, view: 'number', type: 'number', },
  sysCreatorId: { title: '创建人', order: 12, view: 'text', type: 'string', },
  sysCreateDate: { title: '创建日期', order: 13, view: 'datetime', type: 'string', },
  sysUpdatorId: { title: '修改人', order: 14, view: 'text', type: 'string', },
  sysUpdateDate: { title: '修改日期', order: 15, view: 'datetime', type: 'string', },
  modeName: { title: '折算方式名称', order: 16, view: 'text', type: 'string', },
  saveCode: { title: '储存字段', order: 17, view: 'text', type: 'string', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}